package secondStage.part3.泛型.泛型类;

/**
 * @ClassName: [GenericDemo1]
 * @Description: 泛型类
 * @Author: [黄劲松]
 * @CreateDate: [2021-04-03]
 * @Version: [v1.0]
 */
/*
4.2泛型类泛型类的定义格式:
格式:修饰符class类名<类型>{ }
范例: public class Generic<T> { }
    此处T可以随便写为任意标识，常见的如T、E、K、V等形式的参数常用于表示泛型
*/
public class GenericDemo1 {
    public static void main(String[] args) {
        Student s = new Student();
        s.setName("林天");
        System.out.println(s.getName());

        Teacher t = new Teacher();
        t.setAge(111);
        System.out.println(t.getAge());

        System.out.println("-----泛型类使用-----");
        Generic<String> g1 = new Generic<String>();
        g1.setT("张敏");
        System.out.println(g1.getT());

        Generic<Integer> g2 = new Generic<Integer>();
        g2.setT(234);
        System.out.println(g2.getT());

        Generic<Boolean> g3 = new Generic<Boolean>();
        g3.setT(true);
        System.out.println(g3.getT());
    }
}
